<%--
  Created by IntelliJ IDEA.
  User: hasee
  Date: 2021/12/2
  Time: 16:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel = "stylesheet" href = "${pageContext.request.contextPath}/common/layui/css/layui.css">
    <script src = "${pageContext.request.contextPath}/common/jquery3.6.0.js"></script>
    <script src = "${pageContext.request.contextPath}/common/layui/layui.js"></script>
</head>
<body>
<div style = "margin:0px;padding:0px;">
    <!-- 内容主体区域 -->
    <table id="demo" lay-filter="test"></table>
    <div style="padding: 15px;">
    </div>
</div>


<script type = "text/javascript">

    layui.use(['table'], function() {
        var table = layui.table;
        table.render
        ({
            elem: '#demo',
            url: "${pageContext.request.contextPath}/back/getAuditTitleTable",
            page: {limits:[10,15,20,30,50],limit:10}, //开启分页
            cols:[[
                {title: "帖子UUID",field:"auditTitleUUID",sort:true},
                {title: "标题",field:"auditTitleCaption",sort:true},
                {title: "标签",field:"auditTitleLabel",sort:true},
                {title:"年龄限制",field:"auditAgeLimit",sort:true},
                {title:"原创",field:"auditOrginal",sort:true},
                {title:"上传时间",field:"auditUploadTime",sort:true},
                {title: '操作',toolbar: '#barDemo'}
            ]],
            limit:2,
            limits:[2,3,5],
            request: {
                pageName: 'page',   // 页码的参数名称，默认：page
                limitName: 'size'   // 每页数据量的参数名，默认：limit
            },
            id:"showNotice"
        });

        table.on('tool(test)', function(obj) {
            var dt = obj.data;
            if (obj.event === 'goto') {
                $.ajax({
                    url:"${pageContext.request.contextPath}/back/initBackAuditTitle",
                    data:{"uuid":dt.auditTitleUUID},
                    dataType:"json",
                    type:"post",
                    success:function(req)
                    {
                        if (req.flag == 1)
                            location.href = "${pageContext.request.contextPath}/back/gotoBackAuditTitle";
                    }
                });


                /*
                layer.confirm('删除?', function (index) {
                    layer.msg("点击信息");
                });
                */
            }else if (obj.event === 'del'){
                layer.confirm('确定要删除这条审核帖子吗?', {
                    btn: ['确定','我按错了'] //按钮
                },function(){
                    $.ajax({
                        url: "${pageContext.request.contextPath}/back/deleteAuditTitle",
                        type: "POST",
                        data: {uuid: dt.auditTitleUUID},
                        dataType:"json",
                        success:function(req)
                        {
                            if (req.flag == 1){
                                table.reload('showNotice');
                                layer.msg("删除帖子成功");

                            }
                        }
                    });
                }, function(){
                    layer.msg("");
                });
            }
        });

    });

</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="goto">查看</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


</body>
</html>
